package com.hanson.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hanson.mapper.GoodsSellPointParameterMapper;
import com.hanson.pojo.vo.GoodsSellPointParameter;
import com.hanson.service.IGoodsSellPointParameterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * <p>
 * 商品参数卖点表 服务实现类
 * </p>
 *
 * @author HansonLee
 * @since 2021-01-08
 */

@Slf4j
@Service
public class GoodsSellPointParameterServiceImpl extends ServiceImpl<GoodsSellPointParameterMapper, GoodsSellPointParameter> implements IGoodsSellPointParameterService {

    @Resource
    private GoodsSellPointParameterMapper goodsSellPointParameterMapper;

    /**
     *
     * 分页查询goodsSellPointParameter
     *
     * @param condition    数据筛选条件
     * @param page      分页对象
     * @return {@link Page< GoodsSellPointParameter>}      传进来的分页对象，封装了查询数据结果集
     * @author HansonLee
     * @date 2021-01-08
     **/
    @Override
    public Page<GoodsSellPointParameter> list(String condition, Page<GoodsSellPointParameter> page) {
        QueryWrapper<GoodsSellPointParameter> wrapper = new QueryWrapper<GoodsSellPointParameter>();
        GoodsSellPointParameter goodsSellPointParameter = new GoodsSellPointParameter();
        //↓↓↓↓↓↓↓↓为GoodsSellPointParameter查询对象设置条件set condition↓↓↓↓↓↓↓↓

        //↑↑↑↑↑↑↑↑为GoodsSellPointParameter查询对象设置条件set condition↑↑↑↑↑↑↑↑
        wrapper.setEntity(goodsSellPointParameter);
        return super.page(page,wrapper);
    }

    /**
     *
     * 添加新goodsSellPointParameter
     *
     * @param goodsSellPointParameter      需要添加的goodsSellPointParameter
     * @return {@link Object}
     * @author HansonLee
     * @date 2021-01-08
     **/
    @Override
    public Object add(GoodsSellPointParameter goodsSellPointParameter) {
        return super.save(goodsSellPointParameter);
    }

    /**
     *
     * 根据条件更新goodsSellPointParameter
     *
     * @param condition     新数据以及更新条件，使用goodsSellPointParameter实体类封装
     * @return {@link Object}
     * @author HansonLee
     * @date 2021-01-08
    **/
    @Override
    public Object update(GoodsSellPointParameter condition) {
        //条件封装类
        UpdateWrapper<GoodsSellPointParameter> wrapper = new UpdateWrapper<GoodsSellPointParameter>();
        wrapper.setEntity(condition);
        //封装更新条件，wrapper.eq(String column,Object value),column表示数据库字段，value是字段对应的值

        return super.update(condition,wrapper);
    }

    /**
     *
     * 根据条件删除goodsSellPointParameter
     *
     * @param condition     删除条件，使用goodsSellPointParameter实体类封装
     * @return {@link Object}
     * @author HansonLee
     * @date 2021-01-08
     **/
    @Override
    public Object delete(GoodsSellPointParameter condition) {
        //条件封装类
        UpdateWrapper<GoodsSellPointParameter> wrapper = new UpdateWrapper<GoodsSellPointParameter>();
        wrapper.setEntity(condition);
        //封装删除条件，wrapper.eq(String column,Object value),column表示数据库字段，value是字段对应的值

        return super.remove(wrapper);
    }

    /**
     *
     * 根据id删除goodsSellPointParameter
     *
     * @param id     删除条件，需要删除的id
     * @return {@link Object}
     * @author HansonLee
     * @date 2021-01-08
     **/
    @Override
    public Object deleteById(Serializable id) {
        return super.removeById(id);
    }
}
